package com.learn.hibernatevalidator.chapter02.builtinconstraints;

import jakarta.validation.constraints.*;
import lombok.Data;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: liyf
 * @create: 2024-12-22 16:39
 **/
@Data
public class DataInfo {

    @AssertTrue
    private boolean isRequired;

    @AssertFalse
    private Boolean isRegister;


    @DecimalMax(value = "100.99")
    private BigDecimal bigDecimal1;

    @DecimalMax(value = "100.99", inclusive = false)
    private BigDecimal bigDecimal2;

    @DecimalMin(value = "100.99")
    private BigDecimal bigDecimal3;

    @DecimalMin(value = "100.99", inclusive = false)
    private BigDecimal bigDecimal4;

    @DecimalMax(value = "100.99")
    private BigInteger bigInteger1;

    @DecimalMax(value = "100.99", inclusive = false)
    private BigInteger bigInteger2;

    @DecimalMin(value = "100.99")
    private BigInteger bigInteger3;

    @DecimalMin(value = "100.99", inclusive = false)
    private BigInteger bigInteger4;


    /**
     * 整数部分最多2位，小数部分最多2位
     */
    @Digits(integer = 2, fraction = 2)
    private BigDecimal digitsValue1;

    @Email
    private String email;

    /**
     * 未来日期
     */
    @Future
    private LocalDateTime futureDateTime;


    @FutureOrPresent
    private LocalDateTime futureOrPresentDate;

    @Max(7)
    private int weekly;

    @Max(7)
    private Integer weekly2;


    /**
     * 由于 int 有默认值，为了其他测试通过这里设置为了0， 如果设置为1，由于int的默认值为0，就会导致校验失败，使用包装类就没有这个问题.
     */
    @Min(0)
    private int min;

    @Min(1)
    private Integer min2;

    /**
     * 字符串不能为 null 或空(空字符)
     * 只能用在 String 类型上
     */
    @NotBlank
    private String address;


    /**
     * 对于 String 类型不能为null和空(可以是空字符串)
     */
    @NotEmpty
    private String hobby;

    /**
     * 对于集合不能为空
     */
    @NotEmpty
    private List<String> hobbys;


    @NotNull
    private String name;

    @Negative
    private int negativeValue;

    @NegativeOrZero
    private int negativeOrZeroValue;

    @Null
    private String country;

    @Past
    private LocalDateTime pastDateTime;

    @PastOrPresent
    private LocalDateTime pastOrPresentDate;

    @Pattern(regexp = "^\\d{2,4}$")
    private String numberPattern;

    /**
     * 是否为正数，不包括0
     */
    @Positive
    private Integer positiveValue;

    @PositiveOrZero
    private Integer positiveOrZeroValue;

    /**
     * default  min:0
     * max:Integer.MAX_VALUE
     */
    @Size(min = 2, max = 5)
    private String stringSize;

    @Size(min = 2, max = 5)
    private List<String> listSize;
}
